package com.copro.simple;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.copro.chemdb.beans.Account;
import com.copro.chemdb.utils.Constants;

public class SimpleSession {

	private static final String LOGINDATA = "SIMPLE_LOGINDATA";

	public static SimpleSession me(HttpServletRequest request) {
		return new SimpleSession(request.getSession());
	}

	private SimpleSession(HttpSession session) {
		this.session = session;
	}

	private HttpSession session;

	public Application getApplication() {
		return Application.me(session);
	}

	public boolean isLogin() {
		boolean isLogined = false;
		if (null != session.getAttribute(LOGINDATA)) {
			isLogined = true;
		}
		return isLogined;
	}

	public Account getAccount() {
		return (Account) this.session.getAttribute(Constants.USER);
	}

}
